package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.uuid.UUID;
import com.ruoyi.system.domain.OutapiClientConfig;
import com.ruoyi.system.domain.vo.OutapiAppVo;
import com.ruoyi.system.mapper.OutapiClientConfigMapper;
import com.ruoyi.system.service.IOutapiClientConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 对外接口配置实体Service业务层处理
 *
 * @author wjialong
 */
@Service
public class OutapiClientConfigServiceImpl implements IOutapiClientConfigService {
    @Autowired
    private OutapiClientConfigMapper outapiClientConfigMapper;

    /**
     * 查询对外接口配置实体
     *
     * @param id 对外接口配置实体主键
     * @return 对外接口配置实体
     */
    @Override
    public OutapiClientConfig selectOutapiClientConfigById(String id) {
        return outapiClientConfigMapper.selectOutapiClientConfigById(id);
    }

    /**
     * 查询对外接口配置实体列表
     *
     * @param outapiClientConfig 对外接口配置实体
     * @return 对外接口配置实体
     */
    @Override
    public List<OutapiClientConfig> selectOutapiClientConfigList(OutapiClientConfig outapiClientConfig) {
        return outapiClientConfigMapper.selectOutapiClientConfigList(outapiClientConfig);
    }

    @Override
    public Integer selectOutapiClientConfigCount(OutapiClientConfig outapiClientConfig) {
        return outapiClientConfigMapper.selectOutapiClientConfigCount(outapiClientConfig);
    }

    /**
     * 新增对外接口配置实体
     *
     * @param outapiClientConfig 对外接口配置实体
     * @return 结果
     */
    @Override
    public int insertOutapiClientConfig(OutapiClientConfig outapiClientConfig) {
        outapiClientConfig.setCreateTime(DateUtils.getNowDate());
        outapiClientConfig.setId(UUID.fastUUID().toString());
        outapiClientConfig.setAppId(UUID.fastUUID().toString());
        outapiClientConfig.setSecKey("secKey");
        return outapiClientConfigMapper.insertOutapiClientConfig(outapiClientConfig);
    }

    /**
     * 修改对外接口配置实体
     *
     * @param outapiClientConfig 对外接口配置实体
     * @return 结果
     */
    @Override
    public int updateOutapiClientConfig(OutapiClientConfig outapiClientConfig) {
        return outapiClientConfigMapper.updateOutapiClientConfig(outapiClientConfig);
    }

    /**
     * 批量删除对外接口配置实体
     *
     * @param ids 需要删除的对外接口配置实体主键
     * @return 结果
     */
    @Override
    public int deleteOutapiClientConfigByIds(String[] ids) {
        return outapiClientConfigMapper.deleteOutapiClientConfigByIds(ids);
    }

    /**
     * 删除对外接口配置实体信息
     *
     * @param id 对外接口配置实体主键
     * @return 结果
     */
    @Override
    public int deleteOutapiClientConfigById(String id) {
        return outapiClientConfigMapper.deleteOutapiClientConfigById(id);
    }

    @Override
    public List<OutapiAppVo> selectOutapiAppVoList(OutapiClientConfig outapiClientConfig,
                                                   Double maxTime, Double minTime) {
        return outapiClientConfigMapper.selectOutapiAppVoList(outapiClientConfig.getName(),
                outapiClientConfig.getContact(), maxTime, minTime);
    }

}
